﻿Imports System.Data.SqlClient

Public Class clsEvaluacionInternaTotales
    Private mintidEvaluacionInternaTotales As Integer
    Private mintIDEmpleado As Integer
    Private mstrMes As String
    Private mintAnio As Integer
    Private mdblTotal As Double
    Public Property idEvaluacionInternaTotales() As Integer
        Get
            Return mintidEvaluacionInternaTotales
        End Get
        Set(ByVal value As Integer)
            mintidEvaluacionInternaTotales = value
        End Set
    End Property
    Public Property IDEmpleado() As Integer
        Get
            Return mintIDEmpleado
        End Get
        Set(ByVal value As Integer)
            mintIDEmpleado = value
        End Set
    End Property
    Public Property Mes() As String
        Get
            Return mstrMes
        End Get
        Set(ByVal value As String)
            mstrMes = value
        End Set
    End Property
    Public Property Anio() As Integer
        Get
            Return mintAnio
        End Get
        Set(ByVal value As Integer)
            mintAnio = value
        End Set
    End Property

    Public Property Total() As Double
        Get
            Return mdblTotal
        End Get
        Set(ByVal value As Double)
            mdblTotal = value
        End Set
    End Property


    Public Sub New()
        mintidEvaluacionInternaTotales = 0
        mintIDEmpleado = 0
        mstrMes = ""
        mintAnio = 0
        mdblTotal = 0

    End Sub
    Public Sub Borrar()
        Call SetSqlCitra("Delete From EvaluacionInternaTotales Where idempleado = " & IDEmpleado & " and mes='" & Mes.Trim & "' and anio=" & Anio)

    End Sub
Public Sub Insertar()
        Dim sql As String = "Insert Into EvaluacionInternaTotales (" & _
                            "IdEvaluacionInternaTotales," & _
                            "IdEmpleado," & _
                            "Mes," & _
                            "Anio," & _
                            "Total) " & _
                            "VALUES (" & _
                            "@IdEvaluacionInternaTotales," & _
                            "@IdEmpleado," & _
                            "substring(@Mes,1,10)," & _
                            "@Anio," & _
                            "@Total)"

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdEvaluacionInternaTotales", mintidEvaluacionInternaTotales)
        Command.Parameters.AddWithValue("IdEmpleado", mintIDEmpleado)
        Command.Parameters.AddWithValue("Mes", mstrMes)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Total", mdblTotal)

        cnConn.Open()
        Dim RowsAffected As Integer
        Try
            RowsAffected = Command.ExecuteNonQuery
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Aviso")
        End Try

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar la evaluacion", MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
